﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using MockupDesigner.AppItems;

namespace MockupDesigner.Items
{
    public abstract class ResizableItem : ItemBase
    {
        protected bool autochanging = false;

        [Category("Prop_General")]
        public new double Height
        {
            get { return (this.Parent as DesignerItem).Height; }
            set
            {
                if ((this.Parent as DesignerItem).Height != value && !autochanging)
                {
                    OnPropertyChanging("Height", (this.Parent as DesignerItem).Height, value);
                    (this.Parent as DesignerItem).Height = value;
                    OnPropertyChanged("Height");
                }
                if (autochanging)
                {
                    (this.Parent as DesignerItem).Height = value;
                }
                
            }
        }

        [Category("Prop_General")]
        public new double Width
        {
            get { return (this.Parent as DesignerItem).Width; }
            set
            {
                if ((this.Parent as DesignerItem).Width != value && !autochanging)
                {
                    OnPropertyChanging("Width", (this.Parent as DesignerItem).Width, value);
                    (this.Parent as DesignerItem).Width = value;
                    OnPropertyChanged("Width");
                }
                if (autochanging)
                {
                    (this.Parent as DesignerItem).Width = value;
                }
            }
        }

    }
}
